<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html;charset=utf-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld"%>
<%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld"%>
<%request.setCharacterEncoding("utf-8"); %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Shop 管理中心 - 商品详细信息</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<c:url value="/Admin/styles/general.css" />" rel="stylesheet" type="text/css" />
	<link href="<c:url value="/Admin/styles/main.css" />" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="<c:url value='/js/user.js'/>"></script>
    <script language="javascript">
    <c:forEach var="mcTypeMap" items="${mcTypeList}">
    <c:forEach var="me" items="${mcTypeMap}">
        <c:set var="maxType" value="${me.key}" />
        <c:set var="minList" value="${me.value}"/>
    </c:forEach>
        var array_${maxType.nid}=new Array();
        <c:forEach var="minType" items="${minList}" varStatus="lStatus">
            array_${maxType.nid}[${lStatus.index}]="${minType.nid};${minType.sname}";
        </c:forEach>
    </c:forEach>

    function maxChange() {
        var maxtypeObj = document.getElementById("maxType");
        var mintypeObj = document.getElementById("minType");
        
        var maxtype_value = maxtypeObj.value;
        mintypeObj.options.length=0;
        if(maxtype_value!=""){
            mintypeObj.options.add(new Option("请选择....",""));
            document.forms['mcEdit'].elements['minType'].disabled = '';
            var arrayObj = eval("array_" + maxtype_value);
            for(i=0;i<arrayObj.length;i++) {
                var tmp_array=arrayObj[i].split(";");
                mintypeObj.options.add(new Option(tmp_array[1],tmp_array[0]));
            }
        } else {
            document.forms['mcEdit'].elements['minType'].disabled = 'disabled';
        }
    }
    
    function minChange() {
        maxChange();
        var mintypeObj = document.getElementById("minType");
        for(i=0;i<mintypeObj.options.length;i++) {
            if(mintypeObj.options[i].value=="${mc.mcBean.nminid}") {
                mintypeObj.options[i].selected=true;
                break;
            }
        }
    }
    
	function uploadNoPic() {
	
		var nopic=document.getElementById('nopic');
		if(nopic.checked==false){
			document.getElementById('mcimg').disabled="";
			document.getElementById('flag').value="";
		} else if(nopic.checked==true) {
			document.getElementById('mcimg').disabled="disabled";
			document.getElementById('flag').value="nopic.gif";
		}
	}
	</script>
    <c:if test="${not empty param.msg}">
    	<script language="javascript">
			alert('${param.msg}');
			location="<c:url value='/servlet/McInfoServlet' />?mcNid=${param.nid}&fromPage=/Admin/Admin_Mcedit.jsp";
		</script>
    </c:if>
  </head>
  
  <body>
    <h1>
		<span><a href="Admin_Main.jsp">Shop 商品管理</a> - 商品详细信息页 </span>
	</h1>
	<div class="list-div" id="listDiv">
	<form method="post" action="<c:url value='/Admin/McEditServlet'/>" name="mcEdit"  enctype="multipart/form-data" onsubmit="return checkAdminEditMc();">
    <input type="hidden" name="nid" id="nid" value="${mc.mcBean.nid}" />
	  <table cellpadding="0" cellspacing="1">
        <tr>
          <th colspan="4" align="left" style="padding-left:15px;">商品详细信息</th>
        </tr>
          <tr>
            <td width="30%" rowspan="9" align="center"><img src="<c:url value="/mcimg/${mc.mcBean.simg}" />" alt="点击图片查看大图" class="thumb" style="width:200px;height:200px;" /></td>
            <td width="15%" colspan="2" align="right">商品编号：</td>
            <td align="left">&nbsp;&nbsp;&nbsp;${mc.mcBean.nid}</td>
          </tr>
          <tr>
            <td width="15%" colspan="2" align="right">商品名称：</td>
            <td align="left">&nbsp;
              <input name="sname" type="text" value="${mc.mcBean.sname}" /></td>
          </tr>
          <tr>
            <td width="15%" colspan="2" align="right">所属大类：</td>
            <td align="left">&nbsp;
            <select name="maxType" id="maxType" onchange="maxChange();" style="vertical-align:middle;width:147px;">
            <option value="">请选择....</option>
            <c:forEach var="mcTypeMap" items="${mcTypeList}">
            <c:forEach var="me" items="${mcTypeMap}">
            <c:set var="maxType" value="${me.key}" />
            <c:choose>
            <c:when test="${mc.mcBean.nmaxid==maxType.nid}">
                <option value="${maxType.nid}" selected="selected">${maxType.sname}</option>
            </c:when>
            <c:otherwise>
                <option value="${maxType.nid}">${maxType.sname}</option>
            </c:otherwise>
            </c:choose>
            </c:forEach>
            </c:forEach>
            </select>
            </td>
          </tr>
          <tr>
            <td width="15%" colspan="2" align="right">所属小类：</td>
            <td align="left">&nbsp;
            <select name="minType" id="minType" style="vertical-align:middle;width:147px;"></select></td>
          </tr>
          <tr>
            <td width="15%" colspan="2" align="right">是否有货：</td>
            <td align="left">
                <c:choose>
                	<c:when test="${mc.mcBean.smctag=='有货'}">
                	<input name="smctag" type="radio" value="0" checked="checked" />&nbsp;有货&nbsp;<input type="radio" name="smctag" value="1" />&nbsp;缺货&nbsp;
                	</c:when>
                	<c:otherwise>
                	<input name="smctag" type="radio" value="0" />&nbsp;有货&nbsp;<input type="radio" name="smctag" value="1"  checked="checked" />&nbsp;缺货&nbsp;
                	</c:otherwise>
                </c:choose>
            </td>
          </tr>
          <tr>
            <td width="15%" colspan="2" align="right">商品单价：</td>
            <td align="left">&nbsp;
            <input name="nprice" type="text" value="${mc.mcBean.nprice}"/></td>
          </tr>
          <tr>
          	<td width="15%" colspan="2" align="right">商品图片：</td>
          	<td align="left">&nbsp;
          	<input type="hidden" name="oldimg" id="oldimg" value="${mc.mcBean.simg}" />
            <input type="hidden" name="flag" id="flag" value="" /><input type="file" name="mcimg" id="mcimg" title="图片格式只能是.jpg .gif .png .bmp" />
       		<input type="checkbox" name="nopic" id="nopic" onclick="uploadNoPic();" />如不使用商品图片，请打钩!
            </td>
          </tr>
          <tr>
            <td width="15%" colspan="2" align="right" valign="top">商品描述：</td>
            <td align="left">&nbsp;
            <textarea name="sdescription" cols="30" rows="6">${mc.mcBean.sdescription}</textarea></td>
          </tr>
        <tr>
          <td colspan="4" align="left">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="4" align="center" style="border:0px;padding-top:5px;"><input type="submit" value=" 确定修改 " class="button" />&nbsp;&nbsp;
          <input name="button" type="button" onclick="javasctipr:history.back();" value="返回上一页" class="button" /></td>
        </tr>
      </table>
      </form>
	</div>
	<script type="text/javascript">
		window.onload = function()
		{
		  minChange();
		}
	</script>
	<script language="javascript" >
	  <!--
	        var mcname_empty = "商品名称不能为空。";
			var mcprice_empty = "商品单价不能为空";
			var mcprice_msg = "商品价格只能为浮点数";
			var mcimg_msg = "图片格式错误.请重新选择商品图片.\n\n图片格式只能为 gif jpg png bmp";
			var Type_empty = "请选择商品类别";
			var mcimg_empty = "请选择商品图片文件\n\n或点击不使用商品图片"
		-->
	</script>
	<div id="footer">
		版权所有 &copy;
	</div>
  </body>
</html>
